home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
001
/
commdev.arc
/
RS232.DOC
< prev
next >
Wrap
Text File
|
1986-12-04
|
11KB
|
286 lines
RS232 Communications Driver
Version 2.51
Introduction
The purpose of this package is to provide RS232 communications support
in device driver form for both the IBM PC and the Texas Instruments
Professional Computer. All machine dependent code is confined to the device
drivers, so communication programs may be developed that run on either
machine. In addition, the programs may run on any other MS-DOS (2.xx or
greater) machine provided a new device driver is written for that machine.
Communications programs are by nature heavily machine dependent and therefore
are normally not portable to any other machine. There have been some attempts
in the past to use the standard device handle "AUX" to write portable
communications packages. However, the default device drivers for many machines
are inadequate in several areas. The device drivers in this package use the
MS-DOS I/O control channel to configure the driver and to check or change the
modem RS232 signals. Some of the features of the drivers used here that make
them useful for communications are:
o Interrupt driven communications
o Optional flow control
o Access to the modem signals
o Ability to change communication settings without disconnecting
o Ability to force a disconnect by dropping RTS and DTR
o Option to echo RS232 I/O to the CRT
o Option to use both the keyboard and the RS232 port as input
o 110 - 9600 baud rates
o EVEN, ODD, or no parity using 7 or 8 data bits
o Device driver is configured using standard MS-DOS function calls
o Access the number of characters in the receive queue
o Ability to purge the receive queue
These drivers support all the major needs of any communications program,
and are a substantial improvement over most of the default device drivers
that come standard with each MS-DOS computer.
Using these drivers, any language that can write to the device "AUX" can
now do interrupt driven RS232 I/O. If the language is not capable of issuing
the MS-DOS functions call 44 hex (I/O control) to configure the driver, the
assembly program RS232 is provided to set up the port, baud rate, parity,
etc. for the device driver. The source code for this program is provided as
an example of using the MS-DOS I/O control function call. In addition, a
sample TTY program is included as an example. Here's a list of the files
in this package with a brief description of each file:
IBMRS232.ASM Source for IBM PC machine dependent code
IBMRS232.SYS IBM PC RS232 device driver
RS232.ASM Source for RS232 configuration program
RS232.COM RS232 config program
RS232.DOC Documentation for this package
RS232.INC Source for general device driver routines
TIRS232.ASM Source for TI PC machine dependent code
TIRS232.SYS TI PC RS232 device driver
TTY.ASM Source for sample communications program
TTY.COM Sample communications program
Installing the Device Driver
Installing the device driver of your choice is done by editing your
CONFIG.SYS file and putting a copy of the driver in your root directory.
As an example, to install the IBM driver on drive C:, first copy the file
IBMRS232.SYS to C:\IBMRS232.SYS. Next, add the following statement to your
C:\CONFIG.SYS file:
DEVICE = IBMRS232.SYS
The next time you reboot, the driver will be installed and will take the
device name "AUX". The driver will not respond until you configure it by
writing the Device Configuration Word (DCW) to the I/O control channel.
This is accomplished using the MS-DOS function call 44h (hex) and is covered
in the next section.
Using the I/O Control Function Call
All I/O control to the device driver is done in one or two byte forms.
The two byte form is used to set up the communications paramenters. The
single byte form is used to select all other options such as checking the
modem signals. We'll cover the single byte form first. Reading one byte
from the I/O control channel causes the driver return the current modem
signals and I/O configuration. (See function 44h, AL=2 in your MS-DOS manual)
The modem signals and options are encoded as follows:
Bit number
+-------------------------------+
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|-------------------------------|
| KI| EI| EO| RI|SCF|DSR|CTS|DCD|
+-------------------------------+
Bit Description
7 0 = RS232 only is used for input.
1 = Keyboard and RS232 are used for input simultaneously.
6 0 = RS232 input is not echoed to the console display.
1 = RS232 input is echoed to the console display.
5 0 = RS232 output is not echoed to the console display.
1 = RS232 output is echoed to the console display.
4 0 = RI (Ring Indicator) is down.
1 = RI (Ring Indicator) is up.
3 0 = SCF (High speed line) is down.
1 = SCF (High speed line) is up.
* The signal SCF is not supported by the IBM PC.
For the IBM PC, this signal will always be down (0).
2 0 = DSR (Data Set Ready) is down.
1 = DSR (Data Set Ready) is up.
1 0 = CTS (Clear to Send) is down.
1 = CTS (Clear to Send) is up.
0 0 = DCD (Data Carrier Detect) is down.
1 = DCD (Data Carrier Detect) is up.
Writing a single byte to the I/O control channel (function 44h, AL=3)
is used to set the driver options, flush the receive buffer, and disconnect
(by dropping RTS and DTR). Below is a chart showing the various values for
the byte code and the action taken:
Bit number
+-------------------------------+
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|-------------------------------|
| KI| EI| EO| | |LEN|FIB|DTR|
+-------------------------------+
Name Bit Description
KI 7 0 = RS232 only is used for input.
1 = Keyboard and RS232 are used for input simultaneously.
EI 6 0 = RS232 input is not echoed to the console display.
1 = RS232 input is echoed to the console display.
EO 5 0 = RS232 output is not echoed to the console display.
1 = RS232 output is echoed to the console display.
4 Reserved
3 Reserved
LEN 2 0 = Output DCW on 2 byte I/O channel reads. (Default)
1 = Output receive queue length on 2 byte I/O channel reads.
* Note that this field need only be set once. The current
state is used until LEN is changed again.
FIB 1 0 = Don't flush receive buffer
1 = Flush receive buffer
DTR 0 0 = Disconnect (drop DTR and RTS) and reset driver.
1 = DTR and RTS up.
The two byte form of I/O control can be used to read or write the
communications settings. Writing a 2 byte value to the control channel
will set the Device Configuration Word (DCW). Reading 2 bytes from the
control channel will do one of two things depending on the state of the
LEN bit. (The LEN bit is set by the user in the single byte control channel
write.) If LEN = 0, the DCW will be read. If LEN = 1, the receive buffer
length is read. The default mode is LEN = 0, read the DCW. Below is a bit
map showing the various fields within the Device Control Word:
+-------------------------------+-------------------------------+
| Upper Byte | Lower Byte |
+-------------------------------+-------------------------------+
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+-------------------------------+-------------------------------+
| 1 | 2 | 0 | 3 | 3 | 0 | 4 | 4 | 5 | 5 | 5 | 5 | 6 | 7 | 8 | 8 |
+-------------------------------+-------------------------------+
| Bit Codes |
+-------------------------------+-------------------------------+
Bit Code Description
0 Unused but reserved for future use.
1 Port type
0 = parallel (not supported by this driver)
1 = serial
2 Number of data bits
0 = 7 data bits
1 = 8 data bits
3 Port Number
00 = Port 1
01 = Port 2
10 = Port 3 (Port 1 on IBM PC)
11 = Port 4 (Port 2 on IBM PC)
4 Flow Control
00 = none
01 = SCF (NONE for IBM PC)
10 = DSR
11 = XON-XOFF
5 Baud Rate
0000 = 110
0001 = 150
0010 = 300
0011 = 600
0100 = 1200
0101 = 2400
0110 = 4800
0111 = 9600
1000 = 19200
6 Number of Stop Bits
0 = 1
1 = 2
7 Internal Modem
0 = No TI internal modem
1 = Use TI internal modem
* This field must be 0 for the IBM PC
8 Parity
00 = none
01 = ODD
10 = none
11 = EVEN
Writing a New Driver
Additional RS232 drivers may be written for other MS-DOS (2.xx and greater)
machines by changing the machine dependent portion of the driver. The two
drivers provided here have their machine dependent code in IBMRS232.ASM and
TIRS232.ASM. The file RS232.INC is an include file and provides the general
device driver functions. Any general changes to the driver should be made
here. To make a new driver, only the machine dependent portion needs to be
written, and any new driver should also use the INCLUDE directive to add the
code from RS232.INC. Following this form will make maintaining the various
drivers much easier.
Some Final Notes
It should be noted that the TI multifunction card clock driver has a bug in
it that makes TIRS232 lock up. There is a patch floating around for the
multifunction card clock that corrects this problem.
I would like to see as many machines as possible supported by this driver.
It is my goal to see serial communications for MS-DOS machines standardized.
If you add any machines, I would appreciate a copy of the machine dependent
portion of the driver so I may add it to this package. If you have any
questions about this package or suggestions for later versions, I may be
contacted at the address below:
Greg Haley
Texas Instruments
P.O. Box 405 M/S 3454
Lewisville, TX 75067
Happy coding,
Greg Haley
MS is a registered trademark of Microsoft Corporation.
IBM is a registered trademark of International Business Machines Corporation.